package com.itshi.plic;

import java.sql.*;

/**
 * @author げっしょく
 * @date 2021/8/20
 */
public class Test5 {
    public static void main(String[] args) throws Exception{
        Class.forName("com.mysql.jdbc.Driver");
        Connection con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/song?useSSL=false", "root", "1234");
        String username = "zhangsan";
        String password = "1234";
        String sql = "select * from userd where username=? and password=?";
        PreparedStatement ps = con.prepareStatement(sql);
        ps.setString(1,username);
        ps.setString(2,password);
        ResultSet result = ps.executeQuery();
        while(result.next()){
            String string = result.getString(1);
            String string2 = result.getString(2);
            System.out.println(string);
            System.out.println(string2);
        }
        con.close();
        ps.close();
        result.close();
    }
}
